package io;
/*
缓冲字符流：最常用的读写字符串的流

PrintWriter:按行写入数据
 */

import java.io.*;
import java.nio.charset.StandardCharsets;

public class PWDemo {
    public static void main(String[] args) throws IOException {
        //最常用写入字符串方式：
        //底层连接了BufferedWriter,连接了OutputStreamWriter,连接了FileOutputStream
        PrintWriter pw=new PrintWriter("pw.txt");
        pw.println("和我在成都的街头走一走，哦哦哦。。。");
        pw.println("直到所有灯都熄灭了也不停留");
        System.out.println("写出完毕");
        pw.close();
        /*
        FileOutputStream fos=new FileOutputStream("pw.txt");
        OutputStreamWriter osw=new OutputStreamWriter(fos, StandardCharsets.UTF_8);
        BufferedWriter bw=new BufferedWriter(osw);
        PrintWriter pw=new PrintWriter(bw);

        pw.write("和我在成都的街头走一走，哦哦哦。。。");
        bw.write("直到所有灯都熄灭也不停留");
        bw.close();
        System.out.println("写出完毕");

         */


    }
}
